<?php


namespace app\dao\exam;


use app\dao\BaseDao;
use app\model\exam\ExamStatus;

class ExamStatusDao extends BaseDao
{
    public function setModel(): string
    {
        return ExamStatus::class;
    }

    //-----------------------------api------------------------------------------------

    /*
     * 保存学生考试状态
     */
    public function createInformation(array $where)
    {

        $data = $this->search()->where('idcard', $where['idcard'])->where('exam_id', $where['exam_id'])->find();
        if (!$data)
            return $this->getModel()
                ->insert($where);

        if ($where['exam_status'] == '已交卷') {
            $data->exam_status = $where['exam_status'];
            $data->end_time = date("Y-m-d H:i", time());
            $data->save();
            return $data;
        }

    }
}